﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace KQ.DCMMP.Common
{
    public static class CharExtension
    {
        /// <summary>
        /// 是否为特殊字符
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool IsRegexSpecial(this Char input)
        {
            string special = @"* . ? + $ ^ [ ] ( ) { } | \ / ";
            string[] specials = special.Split(new char[] { ' ' });
            if (specials != null && specials.Length > 0)
            {
                foreach (string item in specials)
                {
                    if (string.Equals(item, input.ToString()))
                    {
                        return true;
                    }
                }
            }
            /*
            List<char> brackets = new List<char>();
            brackets.Add('(');
            brackets.Add(')');
            brackets.Add('[');
            brackets.Add(']');
            brackets.Add('{');
            brackets.Add(']');

            foreach (char item in brackets)
            {
                if (Char.Equals(input, item))
                {
                    return true;
                }
            }
            */
            return false;
        }

        /// <summary>
        /// 是否为特殊字符
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool IsChinese(this Char input)
        {
            if (input >= 0x4e00 && input <= 0x9fbb)
            {
                return true;
            }

            return false;
        }
    }
}
